package com.ruoyi.web.controller.wnjk.physical;




import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.system.wnjk.domain.dto.PhysicalDTO;
import com.ruoyi.system.wnjk.domain.po.Physical;
import com.ruoyi.system.wnjk.domain.po.PhysicalPackage;
import com.ruoyi.system.wnjk.service.IPhysicalService;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/physical/package")
public class PackageController extends BaseController {
    @Autowired
    private IPhysicalService physicalService;

    /**
     * 分页+搜索
     * @param
     * @return
     */
    @PreAuthorize("@ss.hasPermi('physical:package:list')")
    @Operation(summary = "分页+搜索")
    @PostMapping("/search")
    public TableDataInfo listSearch(@RequestBody PhysicalDTO physicalDTO){
        startPage();
        List<Physical>  physicalList = physicalService.listSearch(physicalDTO);
        System.out.println(physicalList);
        return getDataTable(physicalList);
    }

    /**
     * 获取体检内容（套餐信息）详细信息
     */
    @PreAuthorize("@ss.hasPermi('physical:package:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(physicalService.selectWnjkPhysicalExaminationPackageById(id));
    }

    /**
     * 新增体检内容（套餐信息）
     */
    @PreAuthorize("@ss.hasPermi('physical:package:add')")
    @PostMapping
    public AjaxResult add(@RequestBody PhysicalPackage physicalPackage)
    {
        return toAjax(physicalService.insertWnjkPhysicalExaminationPackage(physicalPackage));
    }

    /**
     * 修改体检内容（套餐信息）
     */
    @PreAuthorize("@ss.hasPermi('physical:package:edit')")
    @PutMapping
    public AjaxResult edit(@RequestBody PhysicalPackage physicalPackage)
    {
        return toAjax(physicalService.updateWnjkPhysicalExaminationPackage(physicalPackage));
    }

    /**
     * 删除体检内容（套餐信息）
     */
    @PreAuthorize("@ss.hasPermi('physical:package:remove')")
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(physicalService.deleteWnjkPhysicalExaminationPackageByIds(ids));
    }


}
